package com.myplaces.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.maps.client.MapType;
import com.google.gwt.maps.client.MapWidget;
import com.google.gwt.maps.client.control.LargeMapControl3D;
import com.google.gwt.maps.client.control.MenuMapTypeControl;
import com.google.gwt.maps.client.control.OverviewMapControl;
import com.google.gwt.maps.client.control.ScaleControl;
import com.google.gwt.maps.client.geom.LatLng;
import com.google.gwt.maps.client.overlay.GeoXmlLoadCallback;
import com.google.gwt.maps.client.overlay.GeoXmlOverlay;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HorizontalSplitPanel;
import com.google.gwt.user.client.ui.RootPanel;


public class MyPlaces implements EntryPoint {
	
	private MapWidget map;

	public void onModuleLoad() {
		LatLng point = LatLng.newInstance(0.00, 0.00);
	    map = new MapWidget(point, 2);
	    map.setDoubleClickZoom(true);
	    map.setPinchToZoom(true);
	    map.setScrollWheelZoomEnabled(true);
	    map.setSize("100%", "100%");
	    map.addMapType(MapType.getPhysicalMap());
	    map.addControl(new MenuMapTypeControl());
	    map.addControl(new LargeMapControl3D());
	    map.addControl(new OverviewMapControl());
	    map.addControl(new ScaleControl());
	    
	    HorizontalSplitPanel hsp = new HorizontalSplitPanel();
	    hsp.setSplitPosition("200px");
	    hsp.setRightWidget(map);
	    
	    FlowPanel fp = new FlowPanel();
	    fp.add(new GotoPanel(map));
	    hsp.setLeftWidget(fp);
	    
	    GeoXmlOverlay.load("http://picasaweb.google.com/data/feed/base/user/achautard", new GeoXmlLoadCallback() {
			@Override
			public void onSuccess(String url, GeoXmlOverlay overlay) {
				map.addOverlay(overlay);
			}
			
			@Override
			public void onFailure(String url, Throwable caught) {
				GWT.log(url, caught);
			}
		});
	    
	    RootPanel.get("map").add(hsp);
	}
}
